/*
 * Copyright 2010 bedatadriven
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

/**
 * JacobGen generated file --- do not edit
 *
 * (http://www.bigatti.it/projects/jacobgen)
 */
package com.bedatadriven.mso.core;

import com.google.gwt.core.client.JavaScriptObject;

/** Wrapper for Office.ColorFormat*/
public class ColorFormat extends JavaScriptObject {

	protected ColorFormat() { }
	public native final Object getApplication()/*-{
		return this.Application;
	}-*/;

	public native final int getCreator()/*-{
		return this.Creator;
	}-*/;

	public native final Object getParent()/*-{
		return this.Parent;
	}-*/;

	public native final int getRGB()/*-{
		return this.RGB;
	}-*/;
	
	/**
	 *
	 * @return the RGB value as CSS-style color string
	 */
	public final String getRGBAsHex() {
		int rgb = getRGB();
		int red = rgb & 0x0000FF;
		int green = (rgb & 0x00FF00) >> 8;
		int blue = (rgb & 0xFF0000) >> 16;
		
		return new StringBuilder(7)
			.append("#")
			.append(toHexByte(red))
			.append(toHexByte(green))
			.append(toHexByte(blue))
			.toString();
		
	}
	
	private String toHexByte(int x) {
		if(x <= 0xF) {
			return "0" + Integer.toHexString(x);
		} else {
			return Integer.toHexString(x);
		}
	}

	public native final void setRGB(int value)/*-{
		this.RGB = value;
	}-*/;

	public native final int getSchemeColor()/*-{
		return this.SchemeColor;
	}-*/;

	public native final void setSchemeColor(int value)/*-{
		this.SchemeColor = value;
	}-*/;

	public native final int getType()/*-{
		return this.Type;
	}-*/;

	public native final float getTintAndShade()/*-{
		return this.TintAndShade;
	}-*/;

	public native final void setTintAndShade(float value)/*-{
		this.TintAndShade = value;
	}-*/;

	public native final int getObjectThemeColor()/*-{
		return this.ObjectThemeColor;
	}-*/;

	public native final void setObjectThemeColor(int value)/*-{
		this.ObjectThemeColor = value;
	}-*/;

}
